import * as types from 'store/mutation-types'

class Header {
    constructor(header) {
        // 是否显示header
        this.isShow = (header && header['isShow']) ? header['isShow'] : true
        //标题文字
        this.title = (header && header['title']) ? header['title'] : ''
        //是否显示返回按钮
        this.showBack = (header && header['showBack']) ? header['showBack'] : false
        // 返回键点击事件
        this.backEvent = (header && header['backEvent']) ? header['backEvent'] : null
        // 显示更多
        this.showMore = (header && header['showMore']) ? header['showMore'] : false
        // 更多点击事件
        this.moreEvent = (header && header['moreEvent']) ? header['moreEvent'] : null
    }
}

// initial state
const state = {
    header: new Header()
}

// getters
const getters = {
    header: (state) => {
        return new Header()
    }
}

// mutations
const mutations = {
    [types.UPDATE_HEADER](state, header) {
        Object.assign(state.header, header)
    }
}

export default {
    state,
    getters,
    mutations
}
